<?php
namespace common\models\shop;

use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use common\enums\StatusEnum;
use common\helpers\RegularHelper;

/**
 * This is the model class for table "{{%shop_activity}}".
 *
 */
class ShopActivity extends ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%shop_activity}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title','type','thumb'], 'required'],
            [['type','created_at','status','sort'], 'integer'],
            [['title'], 'string', 'max' => 40],
            [['content'],'string','max'=>100],
            [['thumb'],'string','max'=>200],
            [['link'],'string','max'=>1000],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title'=>'标题',
            'content' => '描述',
            'type' => '类型',
            'thumb' => '预览图',
            'link' => '链接',
            'sort' => '排序',
            'status'=>'状态'
        ];
    }

    /**
     * 场景
     *
     * @return array
     */
    public function scenarios()
    {
        return [
//            'backendCreate' => ['goods_name', 'goods_code','goods_bar','goods_unit','gc_id','member_id','store_id'],
            'default' => array_keys($this->attributeLabels()),
        ];
    }
    /**
     * @return array
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::class,
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
                ],
            ],
        ];
    }
}
